﻿@using Smartstore.Core.Catalog.Attributes

@model AddOrderProductModel

<div id="AddProductAttributeContainer" class="adminContent">
    @foreach (var attribute in Model.ProductVariantAttributes)
    {
        var controlId = attribute.BuildControlId();
        <div class="adminRow">
            <div class="adminTitle">
                <div class="ctl-label">
                    <label for="PriceExclTax">
                        @(attribute.TextPrompt.NullEmpty() ?? attribute.Name)
                    </label>
                </div>
            </div>
            <div class="adminData">
                @switch (attribute.AttributeControlType)
                {
                    case AttributeControlType.DropdownList:
                        {
                            <select name="@(controlId)" id="@(controlId)">
                                <option sm-if="!attribute.IsRequired" value="0">---</option>
                                @foreach (var value in attribute.Values)
                                {
                                    <option attr-selected='(value.IsPreSelected, "selected")' value="@value.Id">@value.Name</option>
                                }
                            </select>
                        }
                        break;
                    case AttributeControlType.RadioList:
                    case AttributeControlType.Boxes:
                    case AttributeControlType.Checkboxes:
                        {
                            foreach (var value in attribute.Values)
                            {
                                <div class="form-check">
                                    <input id="@(controlId)" name="@(controlId)" class="form-check-input"
                                           attr-checked='(value.IsPreSelected, "checked")'
                                           type="@(attribute.AttributeControlType == AttributeControlType.Checkboxes ? "checkbox" : "radio")"
                                           value="@value.Id" />
                                    <label for="@(controlId)" class="form-check-label">@value.Name</label>
                                </div>
                            }
                        }
                        break;
                    case AttributeControlType.TextBox:
                        {
                            <input name="@(controlId)" type="text" id="@(controlId)" class="textBox" />
                        }
                        break;
                    case AttributeControlType.MultilineTextbox:
                        {
                            <textarea cols="20" id="@(controlId)" name="@(controlId)" rows="2" style="height: 150px;"></textarea>
                        }
                        break;
                    case AttributeControlType.Datepicker:
                        {
                            <triple-date-picker day-name="@(controlId + "-day")"
                                                month-name="@(controlId + "-month")"
                                                year-name="@(controlId + "-year")"
                                                begin-year="@DateTime.Now.Year"
                                                end-year="@(DateTime.Now.Year + 1)" />
                        }
                        break;
                    case AttributeControlType.FileUpload:
                        {
                            <input type="file" id="@(controlId)" name="@(controlId)" />
                        }
                        break;
                }
            </div>
        </div>
    }
</div>